package com.example.demo.handler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 * @author gyc
 * @date 2018/1/13
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(MultipartException.class)
    public String handleError(
            MultipartException e,
            RedirectAttributes redirectAttributes
            ){
        redirectAttributes.addFlashAttribute("message",e.getCause().getMessage());
        return "redirect:result";
    }
}
